package hm.edu.cs;

import java.util.ArrayList;
import java.util.List;
import android.os.Parcel;
import android.os.Parcelable;

public class BookList implements Parcelable
{
	private static final long serialVersionUID = 1L;
	public final static String ID = "booklist";	
	private List<Book> list;

	public BookList(Book[] books) {
		list = new ArrayList<Book>();
		for (int i = 0; i < books.length; i++) {
			list.add(books[i]);
		}
	}
	
	public int size()
	{
		return list.size();
	}

	public Book getBook(int position) {
		return list.get(position);
	}

	public Book getBook(String isbn) {
		for (Book book : list) {
			if (book.getIsbn().equals(isbn)) {
				return book;
			}
		}
		return null;
	}

	public void addBook(Book book) {
		if (!list.contains(book)) {
			list.add(book);
		}
	}

	
	@Override
	public int describeContents() {return 0;}

	@Override
	public void writeToParcel(Parcel dest, int flags) {}

}
